package com.servlet;

import com.dao.StudentDao;
import com.vo.StudentVo;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

public class SelectStudentServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public SelectStudentServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String userName= (String) request.getSession().getAttribute("userName");
		String LoginPassword = (String) request.getSession().getAttribute("LoginPassword");
		StudentDao sd = new StudentDao();
		String stuNo = request.getParameter("stuNo");
		String name = request.getParameter("stuName");
		String stuClass=request.getParameter("class");
		String password= request.getParameter("password");
		String idcard = request.getParameter("idcard");

    String sql = "STUDENTNUM like '%" + stuNo+"%' AND STUDENTNAME like '%"+name+"%' AND CLASS like '%"+stuClass+"%' AND PASSWORD like '%"+password+"%' AND IDCARD like '%"+idcard+"%'";
		ArrayList<StudentVo> list = sd.selectStudent(sql);
		request.setAttribute("list", list);
		request.getRequestDispatcher("stu/studentList.jsp").forward(request, response);

	
	}

	public void init() throws ServletException {
		// Put your code here
	}

}
